﻿using MultiLang;
using System;
using System.ComponentModel;
using System.Globalization;

namespace Rsdn.Janus
{
	/// <summary>
	/// TypeConverter для bool
	/// </summary>
	internal class BooleanTypeConverter : BooleanConverter
	{
		public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
			object value, Type destType)
		{
            return (bool)value
                ?
                    ml.ml_string(7, "Да") //SR.BooleanTrue
                : ml.ml_string(8, "Нет"); //SR.BooleanFalse;
		}

		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture,
			object value)
		{
            return (string)value == ml.ml_string(7, "Да"); //SR.BooleanTrue;
		}
	}
}